{extend name="public:base" /}


{block name="content"}


<div style="width: 1000px;height: 250px; padding-top: 30px">
    <div id="from" class="layui-form" data-url='{:url("Configure/save_config")}' >

        {foreach $list as $v}
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 120px;">{$v['remark']? $v['remark'] : ''}</label>
            {if condition="$v['id'] eq 13"}
        
            <div class="layui-input-inline">
                <div class="layui-upload">
                    <button type="button" class="layui-btn" id="test1">上传图片</button>
                    <div class="layui-upload-list">
                        <img src="{$v['value']? $v['value'] : ''}" class="layui-upload-img" id="demo1" width="100px" height="100px">
                        <p id="demoText"></p>
                    </div>
                </div>
            </div>
            <input type="hidden" name="{$v.id}-id" value="{$v['id']? $v['id'] : ''}">
            <input type="hidden" id="fileImg" name="{$v.id}-value" value="{$v['value']? $v['value'] : ''}">
            {else /}
            <div class="layui-input-inline">
                <input type="hidden" name="{$v.id}-id" value="{$v['id']? $v['id'] : ''}">
                <input style="width: 800px;" type="text" name="{$v.id}-value" lay-verify="required" autocomplete="off" class="layui-input" value="{$v['value']? $v['value'] : ''}">
            </div>
            {/if}
        </div>
        {/foreach}

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            </div>
        </div>
    </div>
</div>

{/block}

{block name="javascript"}


<script type="text/javascript">
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form;
        var layer = layui.layer;

        //自定义验证规则


        //监听提交
        form.on('submit(formDemo)', function(data){
            var url = $("#from").attr("data-url");
            $.ajax({
                type: 'POST',
                url: url,
                dataType: 'json',
                data: data.field,
                success: function (da) {
                    layer.open({
                        content: da.msg//
                        ,yes: function(index, layero){
                            layer.close(index);
                        }
                        ,time:3000
                    });
                }
            });

            return false;
        });

    });

    layui.use('upload', function(){
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            ,url: '{:url("Configure/up_image")}' //上传接口
            ,done: function(res){
                if(res.code == 0){
                    var da = res.msg;
                    $('#demo1').attr('src', da.imgUrl); //图片链接（base64）
                    $("#fileImg").val(da.imgUrl);
                }else{
                    return layer.msg('上传失败');
                }
            }

        });
    });

</script>
{/block}